package com.itheima.lambdademo.test3;

import java.util.Random;

public class RandomNumHandlerDemo {
    public static void main(String[] args) {
      int i1 = useRandomNumHandler(new RandomNumHandler() {
            @Override
            public int getNumber() {
                return new Random().nextInt(10) + 1;
            }
        });
        System.out.println(i1);

        int i2 = useRandomNumHandler(() -> new Random().nextInt(10) + 1);
        System.out.println(i2);
    }
    public static int useRandomNumHandler(RandomNumHandler r){
        return r.getNumber();
    }
}
interface RandomNumHandler{
    int getNumber();
}